﻿using System;
using System.Security.Principal;

using SubSonic.SqlGeneration.Schema;


namespace C3.Proto.Core.Model
{
    [Serializable]
    public class User : Base, IPrincipal
    {
        public User(IIdentity identity, string[] roles)
        {
            Identity = identity;
        }
        public User() { }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string Email { get; set; }
        public string Password { get; set; }
        public string Salt { get; set; }
        public IIdentity Identity { get; private set; }
        public string Roles { get; set; }

        public bool IsInRole(string role)
        {
            string[] rolesArray = Roles.Split(';');
            Array.Sort(rolesArray);
            return Array.BinarySearch(rolesArray, role) >= 0 ? true : false;

        }
        
    }

    public class UserDocument
    {
       
        public int Id { get; set; }
        public int UId { get; set; }
        public string Name { get; set; }
        public DateTime CreateDate { get; set; }
        public string DocType { get; set; }
    }
}
